package com.saclub.app.handler;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;

import com.offroader.utils.JsonUtils;
import com.saclub.app.R;
import com.saclub.app.adapter.NewsAdapter;
import com.saclub.app.bean.page.NewsListPage;
import com.saclub.app.bean.part.News;
import com.saclub.app.common.MyPageHelper;
import com.saclub.app.fragment.AccountMyFavFragment;

public class BookMarkListResponseHandler extends MyBaseHttpResponseHandler<AccountMyFavFragment, NewsListPage> implements OnItemClickListener {

	@Override
	public void deal() {

		caller.getList().addAll(page.getNewslist());
		BaseAdapter adapter = new NewsAdapter(caller.getList());
		caller.setAdapter(adapter);
		caller.getListview().setAdapter(adapter);
		caller.getListview().setOnItemClickListener(this);

	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		News news = caller.getList().get(position);

		String url = news.getNewUrl();
		String title = caller.getString(R.string.main_account_my_favorite_title);

		Bundle args = new Bundle();
		args.putString("news", JsonUtils.toJson(news));

		MyPageHelper.webView.showMyWebViewPage(caller.getActivity(), url, title, args);

	}

}